"""

@Time: 2021/1/22 18:41
@Author:
@File: config_class.py
"""

from pydantic import BaseSettings
from typing import Union, List, Dict, Any


class AppConfig(BaseSettings):
    """app启动的相关配置"""
    HOST: str = '127.0.0.1'
    PORT: int = 8444


class UserTokenConfig(BaseSettings):
    """对用户登录时处理token的相关配置"""
    SECRET_KEY: str = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7"  # 通过命令行 `openssl rand -hex 32` 可以生成该安全密钥
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30


class FusekiConfig(BaseSettings):
    """Jena Fuseki的相关配置"""
    HOST: str = "http://localhost"
    PORT: int = 3030
    DB_NAME: str = "test_db"
    COMMON_PREFIX: str = 'http://www.inet.com/kg/faultExpertSys/'  # 本体的共有前缀


class ElasticsearchConfig(BaseSettings):
    """Elasticsearch的相关配置"""
    HOSTS: List[str] = ["http://localhost:9200", ]
    TIMEOUT: int = 200
    KWARGS: Dict[str, Any] = {}

    INDEX_NAME: str = 'fault_expert_sys'


class MySQLConfig(BaseSettings):
    """MySQL的相关配置"""
    HOST: str = "localhost"
    PORT: int = 3306
    DB_NAME: str = "volunteer"
    USERNAME: str = 'root'
    PWD: str = 'yubin3869'


class RedisConfig(BaseSettings):
    """Redis的相关配置"""
    HOST: str = 'localhost'
    PORT: int = 6379
    db: Union[int, str] = 0
    PASSWORD: str = None


class MongoConfig(BaseSettings):
    """MongoDB的相关配置"""
    HOST: str = 'localhost'
    PORT: int = 27017
    DB_NAME: str = 'volunteer'

    ML_MODEL_TEMP_COLLECTION_NAME: str = 'ml_models_temp'  # 模型暂存区的collection
    ML_MODEL_SAVED_COLLECTION_NAME: str = 'ml_models_saved'  # 模型保存区的collection
    ML_MODEL_RELEASED_COLLECTION_NAME: str = 'ml_models_released'  # 模型发布区的collection


class FileUploadConfig(BaseSettings):
    """文件上传的配置"""
    FAULT_CARD_FILE_PATH: str = r'E:\transfer station\fault-sys\fault_info_card'  # 故障信息卡文件的存放路径
    FMEA_CARD_FILE_PATH: str = r'E:\transfer station\fault-sys\fmea_card'  # FMEA卡文件的存放路径